<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/7/16
 * Time: 22:02
 */
defined('IN_TS') or die('Access Denied.');

$userid = aac('user')->isLogin();

switch($ts){

    case "":

        $commentid = intval($_GET['commentid']);

        $strComment = $new['ask']->find('ask_comment',array(
            'commentid'=>$commentid,
        ));

        if($strComment['userid']==$userid){


            $strAsk = $new['ask']->find('ask_topic',array(
                'askid'=>$strComment['askid'],
            ));

            $strComment['comment'] = tsDecode($strComment['comment']);


            $title = '编辑回答';
            include template('answeredit');
        }else{
            tsNotice('非法操作');
        }


        break;

    case "do":

        $askid = intval($_POST['askid']);
        $commentid = intval($_POST['commentid']);
        $comment = tsClean($_POST['comment']);

        if($askid && $commentid && $comment){

            $new['ask']->update('ask_comment',array(
                'commentid'=>$commentid,
                'askid'=>$askid,
                'userid'=>$userid,
            ),array(
                'comment'=>$comment,
            ));


            header('Location: '.tsUrl('ask','question',array('id'=>$askid)));

        }

        break;

}